home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / dtk_demo.zip / TIMER.C < prev    next >
C/C++ Source or Header  |  1991-09-12  |  772b  |  39 lines

  1. /*  TIMER.C
  2.  *  last mod.: 21-AUG-91
  3.  */
  4.  
  5. #include <STDIO.H>
  6. #include <STDLIB.H>
  7. #include <CONIO.H>
  8. #include <L_TIME.H>
  9.  
  10. /*-----------*/
  11. void main(void)
  12. {
  13. int ticks, ch;
  14.  
  15. printf("This program times keypresses.  "
  16.     "Time in seconds or clock ticks? (S/T) ");
  17. while ( ch != 'S' && ch != 'T' )
  18.     {
  19.     ch = getch();
  20.     ch -= 32*(ch>'Z');
  21.     }
  22.  
  23. printf("%c\nPress 'X' to exit, "
  24.     "any other key to time keypresses.\n",ch);
  25.  
  26. ticks = ( ch == 'T' );
  27. time_elapsed(0);        /*  initialize  */
  28. while ( ch = getch() )
  29.     {
  30.     ch -= 32*(ch>'Z');
  31.     if ( ch == 'X' )
  32.         exit(0);
  33.     if ( ticks )
  34.         printf("Ticks elapsed = %lu\n",time_elapsed(1));
  35.     else
  36.         printf("Seconds elapsed = %lu\n",time_elapsed(2));
  37.     }
  38. }
  39.